home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / tnos / tnos100s / enetdump.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-30  |  1.0 KB  |  58 lines

  1. /* Ethernet header tracing routines
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #include <stdio.h>
  5. #include "global.h"
  6. #include "mbuf.h"
  7. #include "enet.h"
  8. #include "trace.h"
  9.  
  10. #ifdef TNOS_68K
  11. #define fprintf traceprintf
  12. #endif
  13.  
  14. void
  15. ether_dump(fp,bpp,check)
  16. FILE *fp;
  17. struct mbuf **bpp;
  18. int check;    /* Not used */
  19. {
  20.     struct ether ehdr;
  21.     char s[20],d[20];
  22.  
  23.     ntohether(&ehdr,bpp);
  24.     pether(s,ehdr.source);
  25.     pether(d,ehdr.dest);
  26.     fprintf(fp,"Ether: len %u %s->%s",ETHERLEN + len_p(*bpp),s,d);
  27.  
  28.     switch(ehdr.type){
  29.         case IP_TYPE:
  30.             fprintf(fp," type IP\n");
  31.             ip_dump(fp,bpp,1);
  32.             break;
  33.         case REVARP_TYPE:
  34.             fprintf(fp," type REVARP\n");
  35.             arp_dump(fp,bpp);
  36.             break;
  37.         case ARP_TYPE:
  38.             fprintf(fp," type ARP\n");
  39.             arp_dump(fp,bpp);
  40.             break;
  41.         default:
  42.             fprintf(fp," type 0x%x\n",ehdr.type);
  43.             break;
  44.     }
  45. }
  46. int
  47. ether_forus(iface,bp)
  48. struct iface *iface;
  49. struct mbuf *bp;
  50. {
  51.     /* Just look at the multicast bit */
  52.  
  53.     if(bp->data[0] & 1)
  54.         return 0;
  55.     else
  56.         return 1;
  57. }
  58.